20

I asked and self-answered ST Micro HAL, stm32f7xx_hal_crc.c How to solve [Warning] dereferencing type-punned pointer will break strict-aliasing rules earlier today. It was closed as too broad.

I think the question was very specific. I believe I have every detail needed in the question to answer it.

I originally had tagged it for C and warnings, which I have now removed. I could see how it isn't necessarily a question about C programs or warnings. Instead it is very specific to the stm32 HAL library. I have had the issue in the question for a long time, and I feel that it would be useful for any other engineer who is developing on an stm32 arm microprocessor.

Is there something wrong with my question, and if so how can I make it acceptable?

14
  • 7
    at a glance, it feels like you may need to focus on the M part of MCVE... but I don't know the tech so I may be very, very, very off there
    – Patrice
    Commented May 17, 2018 at 21:34
  • 1
    Ok, I did put a lot of code there, the disclaimer at the top is needed to comply with ST Micro's licence. You needed to see the #define for __IO to understand the question. I could of replaced all of the references to __IO with volatile, but I wanted others who were working on the library to be able to recognize the code.
    – iamJP
    Commented May 17, 2018 at 21:40
  • 1
    Recognizing the code is good, but it's most important to be able to reproduce the error with as little code as possible. And often, in the act of narrowing down the code to an MCVE, you can even find the solution yourself. :) So it both helps you get an answer faster, and can help you find the answer yourself. (I think the consensus is to keep the license info with your code, but I'm not 100% on that. There's discussions about it here on Meta, though, for sure. I'll see if I can find the latest one.)
    – Kendra
    Commented May 17, 2018 at 21:42
  • 1
    @Kendra Thanks that would be good to know. But since it isn't my code , it is ST Micro's, don't I have to abide by the licence provided by them?
    – iamJP
    Commented May 17, 2018 at 21:51
  • @HansPassant Thanks, the question has been reopened and it even seems to have caught the eye of people who know about the stm32 HAL library.
    – iamJP
    Commented May 17, 2018 at 23:12
  • 3
    SO is like politics, notoriety is a feature and not a bug. Good Q+A that is not notorious enough quickly flies off everybody's radar. You might get more close votes however, just a flag a moderator to ask for some protection when that happens. Commented May 17, 2018 at 23:56
  • 1
    I have contributed to the closure of the question (not the downvoting, mind!). I'll try to provide an answer about why I did that. Commented May 18, 2018 at 9:22
  • 2
    @iamJP Interestingly I'm the only commenter at your question, so it seems you mean me with "caught the eye of people who know about the stm32 HAL library". Incidentally I'm also one of the close-voters and the one being offended personally here (not by yourself, to be clear). Just to make you understand: The rules of SOCVR explicitly disallow a voting-ring. And we are not (the ROs are very strictly enforcing the rules). From what I know about the voters we all judge on our own about a request. There is no automatism. But there are users who welcome every occasion to spread their venom. Commented May 18, 2018 at 11:57
  • I normally don't provide this disclaimer, but I feel I should make clear this time I didn't downvote the question. Commented May 18, 2018 at 13:35
  • 1
    @coldspeed yes I recall that comment, is there a flag comments from Hans mob or does he do self-moderation. The comment wasn't over the edge by my standards. Not sure if that is a recommendation ....
    – rene
    Commented May 18, 2018 at 20:13
  • @rene Likely the same users who found my answer "offensive", or a "personal attack"...
    – cs95
    Commented May 18, 2018 at 20:18
  • @coldspeed it wasn't offensive but you weren't gentle either, me thinks? Still business as usual: a question got closed, someone raises an issues, some agree, some don't. Life moves on after this ...
    – rene
    Commented May 18, 2018 at 20:34
  • @coldspeed Assuming one of the users that you may be referring to is me (if not correct me and either way no offence taken), I wasn't one of the users to flag Hans' comment, while I didn't necessarily agree with it I felt there was no need to act on it, meta is here for things to be discussed and (generally), every comment has it's place, I would've left it there. As for your answer, I'm glad you redacted some of your phrasing before but again, your opinion is as important as everyone elses. I feel like there was a bit of hotheadedness from a number of people here, no hard feelings obviously Commented May 19, 2018 at 1:14
  • @NickA No, I did not pick any names specifically. I did think that whoever had a beef with my answer would also not like Hans' comment because we held the same opinion. Certainly, we are all entitled to our opinions but there are also multiple ways to communicate those opinions, some are less respectful or mindful of other users. Unfortunately, there was a lapse in judgement from my side, I really should have been a little more professional in trying to defend OP. By the way, I still stand by my answer, just not how I delivered it. No hard feelings, and hope to see you on the next issue. ;)
    – cs95
    Commented May 19, 2018 at 3:39

4 Answers 4

8

Apparently, the original question has been re-opened with mod-power, so this is more like a post-mortem answer. Normally I'd ignore this thread for this reason (there is little use in arguing with a mod), but as we 5 close-voters are personally attacked by another answer here "Thankfully, sanity has prevailed …" plus a link to my request, I changed my mind.

  1. As said, it was not just me to close the question, but there were 4 other users agreeing. That's not hiding in the crowd, but making clear 5 users apparently disagree with @coldspeed.
  2. Requests in SOCVR are never automatically followed. We don't mob up as it is implied by the @coldspeed's answer.
  3. Interestingly the author of the harsh (not to call it insulting) answer states he has no stake in the tag (which one?).
  4. Despite the "not to broad" fraction, 4 of the users closing have quite some reps in the C tag, 2 even have a gold badge. Well, I don't like argumentum ad verecundiam, but here we see a tendency.

Now to the question itself: - The question was closed well justified and still is. I fully understand that's unsatisfying for you, but we can't answer all questions. - Your question basically asks to fix your code. - The line shown is mentioned as one example. That implies there are more lines and you expect an answer to fix them all. - Clearing the bug requires more than just a cast in those lines, though. Actually the answer maintains the underlying problem, it does not solve it. - A major problem in C is just because you don't get a diagnostic does not mean the code is correct. That's the pitfall with a weakly typed language like C. The Wumpus in C is called undefined behaviour. - Fixing the problem would involve more changes to the code than some casts. We had a short discussion about this in the comments and it seems you agree with me now after a detour.

So, to answer this question: The question indeed is too broad IMO. I'm honestly not sure how one could fix it so you can get a satisfying answer. Simply asking "I get this error for this particular line" would most likely result in it being one of the hundreds of dupes about strict aliasing. But that would not solve your problem. Nor would it fix future reader's problems.

--

Finally: I re-added the C tag (didn't notice you removed it) because the problem is exactly related to the C language, particularly the strict aliasing rule (that's what the compiler reports). You will find the details in the standard, 6.5p6/7, effective type.

Although it should be clear, with the current policy: this is my personal answer. I don't speak for SOCVR or the other 4 voters.

Update: Nick's answer makes me think I should make clear I did no way intend to "punish you" (either). I mentioned the self-answer just for information it does not really provide the necessary information, so it can't be used as proof the question being not too broad. That mostly because you stated it did solve your problem. Thatt's a reason, too why I jumped into the discussion in the comments. Sorry, I often forget to state explicitly what should be considered naturally until proof of the opposite. Maybe I'm too old-school.

17
  • 2
    First I want to say that I don't have any hard feelings for anyone. The question was closed very quickly and with absolutely 0 feedback to me as to why. Then a box pops up that says too broad which made absolutely no sense to me. There were exactly 3 lines that needed to be changed to fix the warning. I commented them clearly in the code. I only included the 2 relevant functions. Also, I did realize you were the one commenting on my answer, and I do appreciate your feedback.
    – iamJP
    Commented May 18, 2018 at 12:29
  • 1
    As I pointed out in the comments to your answer, silencing the compiler does not mean the issue is fixed. For the current code, it persists, just without notification (which is even worse). But even if had reliably, a question must be written such that it can be answered within site-rules by anyone, not just the question's author. In this case you used implicitly knowledge of the project to have a "solution" for your problem. But that does not mean it fixes the genral problem risen by the question. That's a common problem with most too broad questions which later get a self-answer. … Commented May 18, 2018 at 12:40
  • 1
    My answer did feel 'dirty' to me, I originally had a line in the question asking for feedback on my answer but I removed it after I noticed the downvotes. I will have to disagree about the implicit knowledge of my project. This is a library that many other people use and I was looking for advice from those experts. C experts that are familiar and perhaps currently developing on the HAL library. This is why I removed the C and warning tags from the question.
    – iamJP
    Commented May 18, 2018 at 12:44
  • … Both, the answer not solving the problem, and it using context not given were reasons I added the info about the self-answer in the question. That because there is no voting ring , but the fact an answer exists could be a red herring to users checking your question due to my close-request. Oh, and I don't have a problem with you asking on meta, nor what you wrote at all. Otherwise I'm pretty sure I hadn't taken the time to explain all this so detailed. It's simply because I think you deserve it and I really feel with you about the original problem. Commented May 18, 2018 at 12:44
  • 1
    @iamJP: Once more: your answer is a non-answer. So it just can't count as an answer. And I left comments about it and why it still fails. Sorry, I don't think I can make it any more clear. With all due respect, but you should really try to understand the problem with strict aliasing, the standard is clear, but very compacted (and you have to read a lot more of it to fully comprehend the implications - unfortunate truth is a lot of C programmers never did, expecially in bare-metal embedded. It was not much of a problem with ald and commercial compilers, but modern like gcc and clang … Commented May 18, 2018 at 12:47
  • Note that I didn't accept my answer. Someone could still provide a better one. Do you think I should delete my answer?
    – iamJP
    Commented May 18, 2018 at 12:49
  • 2
    … are well known to exploit all weeaknesses of the code for optimisations (that's why gcc had a bad reputation with embedded engineers who never really learned the C language properly). Commented May 18, 2018 at 12:49
  • @iamJP: Well, I won't advice you about anything. I don't think that would be fair, as I still think your question itself is too broad, i.e. should eventually be deleted (that happens wither automatically or manually, depending on certaion factors). As I (and 4 other users with some reputation in C) have been superseeded by a mod, I just don't care about it. There is enough to do elsewhere here and if I didn't care about the site, I had let it gone right after the re-open. Lastly: You should forget about the HAL and writed drivers for the hardware directly. Less trouble. … Commented May 18, 2018 at 12:54
  • … you still need some fixing for the header file with the registeer definitions. Anonymous unions have proven useful for me here. Commented May 18, 2018 at 12:54
  • I do appreciate your feedback and I also need to get back to work. It does kind of feel like you could of written a valid answer to the question but I will just leave it at thank you for your time.
    – iamJP
    Commented May 18, 2018 at 12:57
  • 3
    I did admit I do not have any experience in the tags under discussion, and was liable to miss key details that would mean the question was too broad. However, I still don't agree with the methods you used to close this question, this user's comments here would suggest they weren't the best. C'mon man, you're dealing with a 300 rep user, cut them some slack. Not everyone's a pundit with C nor should you expect them to be. You could stand to be a bit more humane when dealing with situations like this. My 2c
    – cs95
    Commented May 18, 2018 at 13:09
  • 5
    @coldspeed: First, I was not sure I am interested answereing someone who went the way of insult. Anyway, I'll keep this strict to this comment. That's all you will get, though. 1) There is a difference between how to treat a Q&A on the site and still provide some advice to the user. I provided quite some information to the user; enough he should be able to solve the problem properly. 2) Q&A are not to help the original user; in certain ways that's a by-effect for the one first asking the question. It's for future readers. 3) There are no seperate rules for low-rep user's questions afaik. Commented May 18, 2018 at 13:45
  • 1
    @Olaf Instead of trying to clean up StackOverflow, consider giving questions a day or so before voting them to be deleted. I actually think this should be the norm but what do I know. I don't have your rep. I just think there is a culture of elitism here which makes it hard for new comers to even ask a question.
    – iamJP
    Commented May 20, 2018 at 4:34
  • 1
    @Olaf I think you need to consider the human side of the questions. We are not robots or computers. We should be able to ask questions. If the questions don't live up to your personal standards then move on. Eventually they will be deleted if they lack merit. I'm just trying to say give the new guys some slack. It shouldn't be harder to ask a question here than it is to answer one. Bad questions will fade out on their own merit. We are all humans behind this keyboard.
    – iamJP
    Commented May 20, 2018 at 5:02
  • 4
    Despite the "not to broad" fraction, 4 of the users closing have quite some reps in the C tag, 2 even have a gold badge. - In my experience so far on Stack Overflow, I have usually found that it is precisely these type of users who are overly enthusiastic in closing perfectly well-formed questions. Why this keeps happening over and over again is something I do not understand. Why does the community err on the side of closing than err on the side of welcoming questions? Commented May 20, 2018 at 5:58
3

Note: This post has been revised based on the discussion in the comments under this answer. Most of the inflammatory comments/remarks from the previous version of this answer have been removed.

Let me preface this by saying that nobody should ever be punished for trying to be a positive contributor to the community.

I, for one, do not have any experience in this tag. However, the question seems to tick all the boxes for a question to be an topic—

  1. Has a meaningful title
  2. Introduces/describes the problem well
  3. Describes the warning along with the code that produces it
  4. Has associated code sample

From first glance, your question should not have been closed, even if the answer did not address it properly.

What should've been done was a constructive comment left, possibly a downvote (I'd expect it based on the user(s) you were dealing with), and possibly a better answer, as Hans noted. This did happen sans answer, however I do not approve of the manner in which it was done.

Additionally, your question was posted on the SO Close Vote Reviewers for auditing, and upon further inspection, was closed by other users with experience in the C tag (link redacted, see edit history for link).

The specific close vote reason cited there was—

too broad ("someone make my code compliant" - self-answered, not useful for future readers)

Upon further review, a moderator reopened your question, which I'm glad has been done. I did not agree with the closure of your question, but apparently I'm in the minority. I'll let the majority vote win out here.

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – user3956566
    Commented May 22, 2018 at 12:32
2

As one of the people that voted to close your question I want to explain my reasoning. I voted to close the question roughly 10 minutes after it was posted prior to you updating it to give an example of which line (or one of them, possibly of many), which caused the error.

Because the example wasn't "Complete" (in that it wasn't a full program, see MCVE), it wouldn't be possible to run it to determine exactly where the error was, at least not with a deeper understanding of the language than I have (although there's every chance that I was a bit harsh, I'd had a long day :) ).

Had I seen the question after your first edit had taken place I would certainly have retracted my flag (as I thought I had anyway).

Sorry for this and thanks for bringing it to our attention.


Update

Looking back the the question now that I've had something to eat, the line bothering me the most is:

How can the code be changed to remove the warning without breaking the crc module?

This is a fairly open question which could likely be solved in a variety of different way, if I were to vote to close again (which I can't), I'd probably be close voting as too broad as it was before.


As an aside, another user believed that

someone took it upon themselves to punish you for the answer you wrote

I can't speak for the rest of the reviewers that took part in reviewing your question, but every question/answer that I review is reviewed based upon it's own merits, not the words of someone else and it was in no way meant to "punish you".


Sorry if this isn't the answer that you're looking for but hopefully it gives a bit of closure.

8
  • Your reasoning is understandable from your viewpoint and can accept it. Nevertheless I stand to it being TB, even after the edit. In fact, beforehand, it could have been "no mcve" or "unclear" instead of "too broad". The problem with this particular question is it requires C details to see there are multiple changes necessary, depending on the use-case. Commented May 18, 2018 at 11:02
  • @Olaf I didn't think I did flag is as TB, I thought I flagged it as lacking an MCVE, but the most VTCd reason goes into the closure message, of course I could be mistaken, my reasoning is the same though, lack of an MCVE, if I VTCd as TB that was simply an oversight. Commented May 18, 2018 at 11:05
  • As I reasoned in my answer, it was TB from the beginning. Showing an exemplary line does not change much, Commented May 18, 2018 at 11:17
  • 1
    I agree that the question wasn't complete for a generic C or warning question. This is why I decided to remove the tags for those. I realized that a C expert would not necessarily be able to answer the question. This question is for a much rarer C expert that also is familiar with the library in question. I believe there are some of those on this site.
    – iamJP
    Commented May 18, 2018 at 12:38
  • @iamJP: You should still have left the C tag, as the problem is definitively related to the language standards. In general if a language is involved (and it is clearly if you have a compiler diagnostic). Commented May 18, 2018 at 13:41
  • 1
    I'm just going to comment on the MCVE part. Initially after receiving this feed back I tried to change my question to fit this. At first it wasn't minimal enough, then it was too broad, or maybe the other way around. My point here is that I did put in a good effort to make a good question. It might not be perfect but all of this is subjective. And I still feel like if I left the [c] tag out, this wouldn't of made any notice anywhere.
    – iamJP
    Commented May 20, 2018 at 5:17
  • 1
    Ok I also disagree with this "How can the code be changed to remove the warning without breaking the crc module?" being too broad.
    – iamJP
    Commented May 20, 2018 at 5:32
  • 1
    "This is a fairly open question which could likely be solved in a variety of different way" I disagree, It is a very specific question. All of the code was there to understand it. You could of asked questions. I will concede it "could be solved in a variety of different way". However that is true with every question. In fact, every question can be solved in an infinite number of ways. WHICH IS WHY I WANTED TO KNOW THE OPINION OF OTHERS AND HOPEFULLY FIND A GOOD SOLUTION.
    – iamJP
    Commented May 20, 2018 at 5:38
-5

I voted this question to close as "no MCVE" after having being pointed at it in the SOCVR chatroom by a user I'm beginning to know well. The reasons:

  • the question itself is really long and unclear at first glance
  • it was self-answered at the time, on a very popular tag like C
  • the fact that the user who pointed it out has a good experience in closing questions (even if, agreed, he should cheer up sometimes) and I trust him. So it probably influenced my decision.

Those 2 reasons made me think that OP was posting the Q&A only to get reputation points. I very rarely posted self-answered questions which where well-recieved. When you do that, you have to provide a very good question and a very good answer, or others find that suspicious.

You did the right thing by asking on meta, the meta effect was very positive for you, fine. I also noticed that you deleted your upvoted self-answer (it seemed to be technically criticizeable), respect for doing that.

See, SOCVR isn't a voting ring (you didn't get that many upvotes, well at least not from me), and every close action can be reverted (and it was).

In the current state, the question looks okay (even if it could use some trimming, this copyright think is bad luck and doesn't help clarity). The new answer (inspired by this very user who ended up triggering this discussion, who also edited your question to improve it) seems to solve your issue in a clean way. So noone loses here.

20
  • Well, I appreciate reading your viewpoint. I'm just not really happy with the implications of "war". I did not start a "war (which would hav been my close request or maybe my own, preceeding close-vote). And I don#t see this as war, despite what some commenter seems to try make of it. I voted and requested in SOCVR as I thought (and still think) the question is as I stated too broad. The new answerr provides one solution, but there are others, depending on the actual application. OP disagrees and asked on meta. Which is absolutely ok. That's a fair dispute between reasonable beings. Commented May 18, 2018 at 20:04
  • 1
    … I don't think we should retract to the big-world practice to start a war (be it cyber, trade, cold, media or hot war) and we should not use their terminology, but keep it reasonable and civilized - war is the opposite. (Sorry if I make too much of that word, but it really triggers something in me).. Commented May 18, 2018 at 20:06
  • 1
    I never considered this a "war" either, just actions that were subject to criticism by the community. You are accountable for your actions, and I should damn well be allowed to form my own opinion about it without being accused of personal attacks against users. Granted, the language was harsh, which is why I've toned it town. But I haven't deleted it, because I still believe it was the right thing to do at the time. My answer has also resulted in OP getting constructive criticism on their question resulting in a good, useful Q&A. I consider that a win for everybody.
    – cs95
    Commented May 18, 2018 at 20:25
  • I'm not accusing you of personal attacks. and voting to close/downvoting/whatever is allowed. I'm not going to fight over this. just promised an answer since rene pointed us out the meta post Commented May 18, 2018 at 20:26
  • Of course... should have clarified. It was in response to what Olaf said.
    – cs95
    Commented May 18, 2018 at 20:28
  • 1
    @coldspeed: The criticism OP got was way before the meta post already. Ironically it was the one being attacked here in the first place by two users who gave it. On a sidenote, comments are not to answer, so what I did at the question and self-answer was a bit under the radar in a way. And this is done from time to time for questions not fitting here, but where we can still point into a direction. In case you still don't get it: it is definitively not your or Hans' merits. I consider it quite unfair both of you play the saviours of the world here - unjustified at least. Commented May 19, 2018 at 0:47
  • 3
    @Olaf: Would you be willing to accept an apology from me and put this behind us? I realise there was a severe lapse in judgement as to how I delivered my answer. I still stand by my defence, but not how I delivered it. There are ways to put your point across and still be respectful and mindful of the feeling of others, and I overstepped that limit. Please accept my sincerest apologies, I am still learning. Thank you.
    – cs95
    Commented May 19, 2018 at 3:42
  • 2
    You have to understand it is a known pattern that you are generally unkind to askers in the C tag. Having been personally affected by this, I know. That is why, this incident pushed me a little past my sense of reason to post a heated response to your actions. I still remain critical, but I may do so without any disrespect to your person.
    – cs95
    Commented May 19, 2018 at 3:45
  • @coldspeed: Appologiess accepted. I, however disagree about the "unkind" part. First, I hardly commented at all for quite some time now. 2) I'm typically strict to the point, that#s true. But if read carefully, my comments typically are advising helpful actions OP should take. In the C tag which I mostly roam, it just happens to boil down to "RTFineM"/get a book. youtube is fine for cat or music videos, but not to learn C, less engineering. It might be different in your field. 3) I'm not californicated, I'm direct and that's what's considered polite in my culture. 4) Assume good faith. Commented May 19, 2018 at 14:20
  • @coldspeed: specifically AGF is a nother principle. Unfortunately it is completely ignored now and "be nice" and "assume bad intend" seems to be the only policy, not only since the blog post, but massively increasing since then. Finally, support for anything else than kneeing before help-vamps and folks unwilling to even do the least research seems to be suppressed by officials. Anyway, I'll leave it here. Commented May 19, 2018 at 14:24
  • 1
    guys could you comment under Olaf post? I'm getting the notifications, and personally I've moved on :) Commented May 19, 2018 at 15:55
  • "Those 2 reasons made me think that OP was posting the Q&A only to get reputation points. " I just want to defend myself here by stating that I didn't get any rep for answering my own question. In my original question I asked people to critique my answer. I removed that after getting downvotes. I actually wrote the question the day before. The act of writing the question gave me an idea on how to fix it. I didn't feel quite right about my answer, but it passed every test I could throw at it. After spending so much time on the question. I posted it here hoping it would help someone...
    – iamJP
    Commented May 20, 2018 at 2:02
  • or at the very least someone might provide a better answer and tell me why I was doing it wrong.
    – iamJP
    Commented May 20, 2018 at 2:03
  • I would like to also point out that the question was answerable as written. The edits to it were very minor. In the end the first person to say it was "Too Broad" was also the person who answered it (although through hints in comments). All due respects to you Olaf. I did feel personally attacked when the question was closed so abruptly without any feedback. I tried really hard not to act emotionally...
    – iamJP
    Commented May 20, 2018 at 2:17
  • 1
    wow first time for me on such an issue, you won't find a lot of people to complain about my "closing style". So see it as a mistake if you want, and let it go. I was considering deleting this answer to stop getting 25000 comments about the whole thread. But I promised that I would answer... even if I knew that was going to be downvote party. Commented May 20, 2018 at 7:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .