Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

NodeBB

  1. Home
  2. uncategorized
  3. today in C nonsense: a declaration is available in it's initialization expression:

today in C nonsense: a declaration is available in it's initialization expression:

Scheduled Pinned Locked Moved uncategorized
12 Posts 5 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • a1ba@suya.placeA a1ba@suya.place
    @karolherbst iirc gcc can catch it with -Winit-self
    karolherbst@chaos.socialK This user is from outside of this forum
    karolherbst@chaos.socialK This user is from outside of this forum
    karolherbst@chaos.social
    wrote last edited by
    #3

    @a1ba C would be 100 times better if such warnings would be errors instead by default

    a1ba@suya.placeA 1 Reply Last reply
    0
    • karolherbst@chaos.socialK karolherbst@chaos.social

      @a1ba C would be 100 times better if such warnings would be errors instead by default

      a1ba@suya.placeA This user is from outside of this forum
      a1ba@suya.placeA This user is from outside of this forum
      a1ba@suya.place
      wrote last edited by
      #4
      @karolherbst I kinda like that modern good compilers allows forcing warnings into errors and also has a lot of diagnostics...

      but also it's sad that useless tricks like this not strictly violating the standard and compilers wouldn't turn such diagnostics into errors by default
      mildsunrise@tech.lgbtM lanodan@queer.hacktivis.meL 2 Replies Last reply
      0
      • a1ba@suya.placeA a1ba@suya.place
        @karolherbst I kinda like that modern good compilers allows forcing warnings into errors and also has a lot of diagnostics...

        but also it's sad that useless tricks like this not strictly violating the standard and compilers wouldn't turn such diagnostics into errors by default
        mildsunrise@tech.lgbtM This user is from outside of this forum
        mildsunrise@tech.lgbtM This user is from outside of this forum
        mildsunrise@tech.lgbt
        wrote last edited by
        #5

        @a1ba @karolherbst by "not strictly violating the standard you mean this is not UB? i thought it was

        a1ba@suya.placeA 1 Reply Last reply
        0
        • a1ba@suya.placeA a1ba@suya.place
          @karolherbst I kinda like that modern good compilers allows forcing warnings into errors and also has a lot of diagnostics...

          but also it's sad that useless tricks like this not strictly violating the standard and compilers wouldn't turn such diagnostics into errors by default
          lanodan@queer.hacktivis.meL This user is from outside of this forum
          lanodan@queer.hacktivis.meL This user is from outside of this forum
          lanodan@queer.hacktivis.me
          wrote last edited by
          #6
          @a1ba @karolherbst And well modern C compilers have also gradually been turning warnings into errors, of course gradual because C is way too critical and widespread to have massive breaking changes from one compiler version to the other.
          a1ba@suya.placeA 1 Reply Last reply
          0
          • mildsunrise@tech.lgbtM mildsunrise@tech.lgbt

            @a1ba @karolherbst by "not strictly violating the standard you mean this is not UB? i thought it was

            a1ba@suya.placeA This user is from outside of this forum
            a1ba@suya.placeA This user is from outside of this forum
            a1ba@suya.place
            wrote last edited by
            #7
            @mildsunrise @karolherbst that's my opinion but I don't think UB is supposed to be treated like standard violation.

            Because if it was, such tricks would've been prohibited, especially in the newer revisions of the standard. But probably that's just me interpreting the word "violation" differently. ๐Ÿ™‚
            1 Reply Last reply
            0
            • lanodan@queer.hacktivis.meL lanodan@queer.hacktivis.me
              @a1ba @karolherbst And well modern C compilers have also gradually been turning warnings into errors, of course gradual because C is way too critical and widespread to have massive breaking changes from one compiler version to the other.
              a1ba@suya.placeA This user is from outside of this forum
              a1ba@suya.placeA This user is from outside of this forum
              a1ba@suya.place
              wrote last edited by
              #8
              @lanodan @karolherbst my "favourite" useless feature of an old C is implicit function declaration. Not sure if it became error by default, because everybody sane just force it into an error by their own.
              1 Reply Last reply
              0
              • a1ba@suya.placeA a1ba@suya.place
                @karolherbst iirc gcc can catch it with -Winit-self
                ? Offline
                ? Offline
                Guest
                wrote last edited by
                #9

                @a1ba @karolherbst

                No, gcc and clang return 0

                a1ba@suya.placeA 1 Reply Last reply
                0
                • ? Guest

                  @a1ba @karolherbst

                  No, gcc and clang return 0

                  a1ba@suya.placeA This user is from outside of this forum
                  a1ba@suya.placeA This user is from outside of this forum
                  a1ba@suya.place
                  wrote last edited by
                  #10
                  @HugeGameArtGD @karolherbst you mean exit successfully? Of course, because that's just the warning.

                  -Werror=xxx forces diagnostic to be an error.
                  ? 1 Reply Last reply
                  0
                  • a1ba@suya.placeA a1ba@suya.place
                    @HugeGameArtGD @karolherbst you mean exit successfully? Of course, because that's just the warning.

                    -Werror=xxx forces diagnostic to be an error.
                    ? Offline
                    ? Offline
                    Guest
                    wrote last edited by
                    #11

                    @a1ba @karolherbst
                    I don't get any warning, compiles fine and returns 0

                    #include <stdio.h>

                    int some_func(void) {
                    int a = a;
                    return a;
                    }

                    int main() {
                    printf("%d", some_func());
                    }

                    a1ba@suya.placeA 1 Reply Last reply
                    0
                    • ? Guest

                      @a1ba @karolherbst
                      I don't get any warning, compiles fine and returns 0

                      #include <stdio.h>

                      int some_func(void) {
                      int a = a;
                      return a;
                      }

                      int main() {
                      printf("%d", some_func());
                      }

                      a1ba@suya.placeA This user is from outside of this forum
                      a1ba@suya.placeA This user is from outside of this forum
                      a1ba@suya.place
                      wrote last edited by
                      #12
                      @HugeGameArtGD @karolherbst well maybe it's not init-self, I don't remember actually ๐Ÿ™‚
                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Login or register to search.
                      Powered by NodeBB Contributors
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups